/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.shsc.db;

import com.bionic.shsc.dao.abstractClasses.DAOFactory;


import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.NamingException;

/**
 *
 * @author Ann
 */
public class DB {

    private DAOFactory daoFactory;
    private Connection connection;
    private static DB instance;

    public static DB getInstance() {
        if (instance == null) {
            instance = new DB();
        }
        return instance;
    }

    private DB() {
        try {
            connection = ConnectionManager.getInstance().getConnection();
        } catch (SQLException e) {
            //log error
        } catch (NamingException e) {
            //   log error
        }
    }

    public Connection getConnection() {
        return connection;
    }

    private void createDAOFActory() {
        daoFactory = DAOFactory.getDAOFactory(DAOFactory.MySQL);
    }

    public DAOFactory getFactory() {
        if (daoFactory == null) {
            createDAOFActory();
        }
        return daoFactory;
    }

   
}
